(function(){
	Ext.data.validations.lengthMessage = "错误的长度";
	Ext.onReady(function(){
		Ext.apply(Ext.data.validations,{
			age1:function(config,value){
				if(config.min<= value && value <=config.max){
					return true;
				}else{
					this.age1Message = this.age1Message + "他的范围为"+config.min + "-"+config.max;
					return false;
				}
			},
			age1Message : "年龄不合法"
		})
		
		
		Ext.define("person",{
			extend:"Ext.data.Model",
			fields:[
				{name:'name',type:'auto'},
				{name:'age',type:'int'},
				{name:'email',type:'auto'}
			],
			validations:[
				{type:'length',field:'name',min:2,max:6},
				{type:'age1',field:'age',min:0,max:150}
			]
		});
		
		
		
		var p2 = Ext.create('person',{
			name:'tang111',
			age:255,
			email:'javatzp@163.com'
		});
		var errorinfo = [];
		var erros = p2.validate();
		erros.each(function(v){
			errorinfo.push(v.field+" "+v.message);
		});
		alert(errorinfo.join("\n"));
	});	
})();